<template>
  <div id="app">
    <theme-selector ref="themeSeletorRef" />
    <div class="container-app" @click="hideMenu">
      <add-city v-if="showAddCityPage"/>
      <weather v-else/>

    </div>
  </div>
</template>

<script>


import Weather from "@/views/weather/index";
import getDaytimeChange from '@/mixins/getDaytimeChange';
import eventBus from "@/util/eventBus";
import AddCity from "@/views/add-city/index";
import ThemeSelector from "@/components/theme-selector";
import eventBusMap from "@/config/constant/eventBusMap";

export default {
  name: 'App',
  mixins: [getDaytimeChange],
  components: {
    AddCity,
    Weather,
    ThemeSelector
  },
  data() {
    return {
      timer: null,
      currentBg: 'noon',
      showAddCityPage: false
    }
  },
  computed: {

  },
  created() {
    eventBus.$on(eventBusMap.showAddCityPage, (data = false) => {
      this.showAddCityPage = data;
    });

    console.log('store', this.$store);
  },

  methods: {
    hideMenu() {
      this.$refs['themeSeletorRef'].hideMenu();
    }
  },

  beforeDestroy() {
    clearInterval(this.timer);
  }

}
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: MILT_RG;
  // 禁用选择事件
  -moz-user-select:none;
  -webkit-user-select:none;
  user-select:none;
}

body {
  height: 100vh;
  width: 100%;
  //background-color: #94c3ff;
  //background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
  //background-image: linear-gradient(180deg, #a1c4fd 30%, #ffb337 100%);
  //background-image: linear-gradient(120deg, #6190e8 30%, #a7bfe8 100%);
  //background-image: linear-gradient(to top, #425e8b 0%, #4778d5 1%, #2a5298 100%);
  //background-image: linear-gradient(120deg, #66a6ff 0%, #7fcffd 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  position: relative;
}

#app {
  @media screen and (min-width: 540px) {
    width: 100%;
    margin: 0 auto;
  }
}

.container-app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #fff;
  width: 100%;
  height: 100vh;

  //padding-left: 24px;
  //padding-right: 24px;
  //overflow: hidden;

  @media screen and (min-width: 540px) {
    width: 375px;
    margin: 0 auto;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    //border: red 1px solid;
  }

  @media screen and (max-width: 540px) {
    height: 100vh;
  }
}

.show-border {
  border: 1px solid red;
}

@font-face {
  font-family: MILT_RG;
  font-face-name: MILT_RG;
  src: url("assets/font/MILT_RG.ttf");
  font-display: swap;
}

@keyframes starTwinkle {
  0% {
    background-color: rgba(255,255,255, .2);
    transform: scale(0);
  }
  50% {
    background-color: rgba(255,255,255, .5);
    transform: scale(0.8);
  }
  100% {
    background-color: rgba(255,255,255, 1);
    transform: scale(1.2);
  }
}

.star {
  position: absolute;
  display: inline-block;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background-color: #fff;
}

</style>
